using System;
using System.Collections.Generic;
using System.Text;
using Mpi.Common.Collections;
using System.ComponentModel;

namespace Xeml.Document.EnvironmentalOntology
{
    public class TypeSpecification
    {
        private VariableDataTypes baseType;
        private List<TypeSpecifics> typeSpecifica;

        public VariableDataTypes BaseType
        {
            get
            {
                return baseType;
            }
            set
            {
                this.baseType = value;
            }
        }

        public System.Collections.Generic.List<TypeSpecifics> TypeSpecifica
        {
            get
            {
                return typeSpecifica;
            }
            
        }

     

        public TypeSpecification()
        {
            this.typeSpecifica = new List<TypeSpecifics>();
        }

        public List<Enum> ListEnums()
        {
            List<Enum> ret = new List<Enum>();
            foreach (TypeSpecifics ts in this.typeSpecifica)
            {
                if (ts is Enum)
                {
                    ret.Add(ts as Enum);
                }
            }
            return ret;

        }

        public List<Exclude> ListExcludes()
        {
            List<Exclude> ret = new List<Exclude>();
            foreach (TypeSpecifics ts in this.typeSpecifica)
            {
                if (ts is Exclude)
                {
                    ret.Add(ts as Exclude);
                }
            }
            return ret;
        }

        public bool HasEnums()
        {
            return this.ListEnums().Count > 0;
        }

        public bool HasExcludes()
        {
            return this.ListExcludes().Count > 0;
        }

        public Min GetMin()
        {
            foreach (TypeSpecifics ts in this.typeSpecifica)
            {
                if (ts is Min)
                    return ts as  Min;
            }
            return null;
        }

        public Max GetMax()
        {
            foreach (TypeSpecifics ts in this.typeSpecifica)
            {
                if (ts is Max)
                    return ts as Max;
            }
            return null;
        }
    }


    public class NamedTypeSpecification : TypeSpecification
    {
        public string Name { get; set; }

        //#region IIdObject<string> Members

        //private IdentifiableObjectCollection<string, NamedTypeSpecification> collection;
        //public IdentifiableObjectCollection<string, NamedTypeSpecification> Collection
        //{
        //    get
        //    {
        //        return this.collection;
        //    }
        //    set
        //    {
        //        if (value == null)
        //        {
        //            this.collection.Remove(this);
        //            this.collection = null;
        //            return;
        //        }

        //        if (!value.Contains(this.ObjectIdentifiere))
        //            throw new ArgumentException("This object is not a member of the target collection");
        //        this.collection = value;

        //    }
        //}

        //[Browsable(false)]
        //public object CollectionObject
        //{
        //    get
        //    {
        //        return this.collection;
        //    }
        //    set
        //    {
        //        this.Collection = (IdentifiableObjectCollection<string, NamedTypeSpecification>)value;
        //    }
        //}

        //public string ObjectIdentifiere
        //{
        //    get { return name; }
        //}

        //#endregion
    }
}
